package cn.edu.jsu.nrs.model;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * TbUser entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "tb_user", catalog = "db_nrs")
public class User implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// Fields

		private Integer userId;
		private String userName;
		private String password;
		private String sex;
		private String avator;
		private Timestamp birthday;
		private String email;
		private Integer isAdmin;
		private Timestamp registerTime;
		private Set<Reply> tbReplies = new HashSet<Reply>(0);

		// Constructors

		/** default constructor */
		public User() {
		}

		/** minimal constructor */
		public User(String userName, String password, String sex,
				Integer isAdmin, Timestamp registerTime) {
			this.userName = userName;
			this.password = password;
			this.sex = sex;
			this.isAdmin = isAdmin;
			this.registerTime = registerTime;
		}

		/** full constructor */
		public User(String userName, String password, String sex, String avator,
				Timestamp birthday, String email, Integer isAdmin,
				Timestamp registerTime, Set<Reply> tbReplies) {
			this.userName = userName;
			this.password = password;
			this.sex = sex;
			this.avator = avator;
			this.birthday = birthday;
			this.email = email;
			this.isAdmin = isAdmin;
			this.registerTime = registerTime;
			this.tbReplies = tbReplies;
		}

		// Property accessors
		@Id
		@GeneratedValue(strategy = IDENTITY)
		@Column(name = "user_id", unique = true, nullable = false)
		public Integer getUserId() {
			return this.userId;
		}

		public void setUserId(Integer userId) {
			this.userId = userId;
		}

		@Column(name = "userName", nullable = false)
		public String getUserName() {
			return this.userName;
		}

		public void setUserName(String userName) {
			this.userName = userName;
		}

		@Column(name = "password", nullable = false)
		public String getPassword() {
			return this.password;
		}

		public void setPassword(String password) {
			this.password = password;
		}

		@Column(name = "sex", nullable = false, length = 6)
		public String getSex() {
			return this.sex;
		}

		public void setSex(String sex) {
			this.sex = sex;
		}

		@Column(name = "avator")
		public String getAvator() {
			return this.avator;
		}

		public void setAvator(String avator) {
			this.avator = avator;
		}

		@Column(name = "birthday", length = 19)
		public Timestamp getBirthday() {
			return this.birthday;
		}

		public void setBirthday(Timestamp birthday) {
			this.birthday = birthday;
		}

		@Column(name = "email")
		public String getEmail() {
			return this.email;
		}

		public void setEmail(String email) {
			this.email = email;
		}

		@Column(name = "is_admin", nullable = false)
		public Integer getIsAdmin() {
			return this.isAdmin;
		}

		public void setIsAdmin(Integer isAdmin) {
			this.isAdmin = isAdmin;
		}

		@Column(name = "registerTime", nullable = true, length = 19)
		public Timestamp getRegisterTime() {
			return this.registerTime;
		}

		public void setRegisterTime(Timestamp registerTime) {
			this.registerTime = registerTime;
		}

		@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbUser")
		public Set<Reply> getTbReplies() {
			return this.tbReplies;
		}

		public void setTbReplies(Set<Reply> tbReplies) {
			this.tbReplies = tbReplies;
		}
}